package cn.bugstack.mybatis.executor;

import cn.bugstack.mybatis.mapping.BoundSql;
import cn.bugstack.mybatis.mapping.MappedStatement;
import cn.bugstack.mybatis.session.ResultHandler;
import cn.bugstack.mybatis.session.RowBounds;
import cn.bugstack.mybatis.transaction.Transaction;

import java.sql.SQLException;
import java.util.List;

/**
 * SqlSession 每个方法的执行都需要经历 datasource、preparedStatement、resultSet等一系列操作
 * 将这部分操作解耦到 Executor
 * @author xing
 */
public interface Executor {

    ResultHandler NO_RESULT_HANDLER = null;

    <E> List<E> query(MappedStatement ms, Object parameter, RowBounds rowBounds, ResultHandler resultHandler, BoundSql boundSql) throws Exception;

    int update(MappedStatement ms, Object parameter) throws Exception;

    void commit(boolean b) throws SQLException;

    Transaction getTransaction();
}
